<template>
<!--  background-color="rgb(52,64,88)"--><!--           :default-openeds="opens"-->
  <el-menu style="min-height: 100vh;"
           background-color="rgb(48, 65, 86)"
           class="el-menu-vertical-demo"
           active-text-color="#ffd04b"
           text-color="#fff"
           :collapse-transition="false"
           router
           :unique-opened="true"
           :collapse="isCollapse">
    <div  style="height: 60px;line-height: 60px;text-align: center;color: #2065e2;font-size: 20px;background-color: rgb(52,64,88)">
      <img src="../assets/logo.png" alt="" style="width: 20px; position: relative; top: 5px;">
      <b v-show="!isCollapse">疫情防控管理系统</b>
    </div>
    <div v-for="item in menu" :key="item.id">
      <div v-if="item.path">
        <el-menu-item class="home-class" :index="item.path">
          <i :class="item.icon"></i>
          <span slot="title">{{item.name}}</span>
        </el-menu-item>
      </div>
      <div v-else>
        <el-submenu :index="item.id+''" >
          <template slot="title">
            <i :class="item.icon"></i>
            <span slot="title">{{item.name}}</span>
          </template>
          <div v-for="subItem in item.children" :key="subItem.id">
            <el-menu-item :index="subItem.path">
              <i :class="subItem.icon"></i>
              <span>{{subItem.name}}</span>
            </el-menu-item>
          </div>
        </el-submenu>
      </div>
    </div>
  </el-menu>
</template>

<script>
export default {
  name: "Aside",
  props:{
    isCollapse: Boolean,
  },
  data(){
    return{
      menu: [],
      opens: localStorage.getItem("menu") ? JSON.parse(localStorage.getItem("menu")).map(v =>v.id+'') : []
    }
  },
  created() {
    this.menu=localStorage.getItem("menu") ? JSON.parse(localStorage.getItem("menu")) : []
  }
}
</script>

<style scoped>
/*.el-menu-item {*/
/*  background-color: rgb(36,45,61);*/
/*}*/
/*.el-menu{*/
/*  background-color: rgb(52,64,88);*/
/*}*/
/*.el-menu-item-group{*/
/*  background-color: rgb(36,45,61);*/
/*}*/
/*.el-menu-item.is-active{*/
/*  background-color: rgb(115,150,190);*/
/*  color: #07D99EF5;*/
/*}*/
/*.home-class{*/
/*  background-color: rgb(52,64,88);*/
/*}*/


.el-menu-item.is-active {
  background-color: rgb(38, 52, 69) !important;
}
.el-menu-item:hover {
  background-color: rgb(38, 52, 69) !important;
}

.el-submenu__title:hover {
  background-color: rgb(38, 52, 69) !important;
}
/*解决收缩菜单文字不消失问题*/
.el-menu--collapse span {
  visibility: hidden;
}
</style>